Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
"type": "module" import issue

Using js librairies, I struggle with the fact that require and import are not suitable together. When I write "type": "module" in the package.json, then import works but require doesn't, and when I don't, the opposite happens. I don't get how to import both of the two librairies.

I import fs like this :

const fs = require('fs')

and in the other file I am importing PythonShell like this :

import { PythonShell } from 'python-shell'

Is there a way to have "type" : "module" only applying for one librairy in my package.json ? Or can I import one like the other in order to use only one key word (import or require) ?

Thank you, have a great day.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You don't necessarily need to use import to use the PythonShell class from python-shell, you can just use require() so your code would look like this

const fs = require('fs');
const PythonShell = require('python-shell').PythonShell;

// ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!